{include file="public/header" /}
<style>
    /*缩略图高度*/
    .layui-table-cell {height: 36px;}
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->

                <!--搜索框结束-->
                <!--操作框开始-->
                <div class="col-sm-12">
                    <div class="input-group">
                        <button class="btn btn-primary" type="button" onclick="wk.layer_show('添加章节', '{:url('sectionAdd')}');">
                            <i class="fa fa-plus"></i> 添加章节
                        </button>

                    </div>
                </div>
                <!--操作框结束-->
            </div>
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="testReload"></table>

                    <!--状态显示模板-->
                    <script type="text/html" id="sectionStatus">
                        {{# if(d.c_section_status == 1){ }}
                        上架中
                        {{# } }}
                        {{# if(d.c_section_status == 2){ }}
                        已下架
                        {{# } }}
                    </script>

                    <!--操作模板-->
                    <script type="text/html" id="opeBar">
                        <a href="javascript:;" onclick="wk.layer_show('查看详情', '{:url('sectionDetail')}?c_section_id={{d.c_section_id}}')" class="btn btn-warning btn-xs m-r-xs" title="详情">详情</a>
                        <a href="javascript:;" onclick="wk.layer_show('编辑章节', '{:url('sectionEdit')}?c_section_id={{d.c_section_id}}')" class="btn btn-primary btn-xs m-r-xs" title="编辑">编辑</a>
                        {{# if(d.c_section_status == 1){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.c_section_id}}','{:url('sectionDown')}', '确定下架？')" class="btn btn-warning btn-xs m-r-xs" title="下架">下架</a>
                        {{# } }}
                        {{# if(d.c_section_status == 2) { }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.c_section_id}}','{:url('sectionOn')}', '确定上架？')" class="btn btn-info btn-xs m-r-xs" title="上架">上架</a>
                        {{# } }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.c_section_id}}','{:url('sectionDel')}')" class="btn btn-danger btn-xs m-r-xs" title="删除">删除</a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
<textarea id="allidsForOut" class="hidden"></textarea>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("Classes/classSection")}'
            , response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
//            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 30]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
//                {type: 'checkbox', fixed: 'left',}
                  {field: 'c_section_id', width: 60, title: 'ID', align: 'center'}
                , {field: 'c_section_name', width: '', title: '章节名称', align: 'center'}
                , {field: 'c_section_sort', width: 100, title: '章节排序', align: 'center'}
                , {field: 'c_section_status', width: 80, title: '状态', align: 'center', toolbar: '#sectionStatus'}
                , {field: 'c_section_time', width: 160, title: '创建时间', align: 'center'}
                , {field: 'c_section_update_time', width: 160, title: '编辑时间', align: 'center'}
                , {fixed: 'right', width: 280, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            , done: function (res, curr, count) {
                $('.img-circle').viewer({
                    url: 'data-original',
                });
            }
        });
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    , data = checkStatus.data;
            $.each(data, function (index, item) {
                ids.push(item['class_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>